#pragma once 

#include "Core\NervusSharedHeader.h"

namespace Nervus {
	namespace Core {

		const u32 NV_KEYSNUMBER = 256;

		class Input {
			friend class Window;

		private:
			HWND* mhWnd;
			POINT mMousePos;
			RECT mWndRect;


			SHORT mKeyState[NV_KEYSNUMBER];
			SHORT mPrevKeyState[NV_KEYSNUMBER];

			i32 mMouseWheel;

			Input();
			Input(HWND* hWnd);
			Input(const Input& root);
			Input& operator=(const Input&);
			//Called from window message processor after WM_MOUSEWHEEL msg
			void wheelMoved(i32 delta);
			~Input();


		public:

			
			

			void updateInput();
			//Returns mouse position within the window
			//If mouse is out of the window, returns (-1;-1)
			D3DXVECTOR2 getMousePos();
			//Is key down for now
			bool isKeyDown(u32 keyCode);

			//Turns to true for 1 logic tick when key was unpressed 
			bool isKeyUnpressed(u32 keyCode);
			//Turns to true for 1 logic tick when key was pressed
			bool isKeyPressed(u32 keyCode);

			//Turns to true for 1 logic tick when mouse wheel was moved up (FROM the user)
			bool isWheelMovedUp();
			//Turns to true for 1 logic tick when mouse wheel was moved down (TO the user)
			bool isWheelMovedDown();





		};


		const u32 NVKC_0 = 0x30;
		const u32 NVKC_1 = 0x31;
		const u32 NVKC_2 = 0x32;
		const u32 NVKC_3 = 0x33;
		const u32 NVKC_4 = 0x34;
		const u32 NVKC_5 = 0x35;
		const u32 NVKC_6 = 0x36;
		const u32 NVKC_7 = 0x37;
		const u32 NVKC_8 = 0x38;
		const u32 NVKC_9 = 0x39;

		const u32 NVKC_A = 0x41;
		const u32 NVKC_B = 0x42;
		const u32 NVKC_C = 0x43;
		const u32 NVKC_D = 0x44;
		const u32 NVKC_E = 0x45;
		const u32 NVKC_F = 0x46;
		const u32 NVKC_G = 0x47;
		const u32 NVKC_H = 0x48;
		const u32 NVKC_I = 0x49;
		const u32 NVKC_J = 0x4A;
		const u32 NVKC_K = 0x4B;
		const u32 NVKC_L = 0x4C;
		const u32 NVKC_M = 0x4D;
		const u32 NVKC_N = 0x4E;
		const u32 NVKC_O = 0x4F;
		const u32 NVKC_P = 0x50;
		const u32 NVKC_Q = 0x51;
		const u32 NVKC_R = 0x52;
		const u32 NVKC_S = 0x53;
		const u32 NVKC_T = 0x54;
		const u32 NVKC_U = 0x55;
		const u32 NVKC_V = 0x56;
		const u32 NVKC_W = 0x57;
		const u32 NVKC_X = 0x58;
		const u32 NVKC_Y = 0x59;
		const u32 NVKC_Z = 0x5A;

		const u32 NVKC_PGUP = 0x21;
		const u32 NVKC_PGDOWN = 0x22;
		const u32 NVKC_END = 0x23;
		const u32 NVKC_HOME = 0x24;
		const u32 NVKC_INSERT = 0x2D;
		const u32 NVKC_DELETE = 0x2E;

		const u32 NVKC_ARROWLEFT = 0x25;
		const u32 NVKC_ARROWUP = 0x26;
		const u32 NVKC_ARROWRIGHT = 0x27;
		const u32 NVKC_ARROWDOWN = 0x28;

		const u32 NVKC_PRINTSCR = 0x2C;
		const u32 NVKC_PAUSE = 0x13;

		const u32 NVKC_F1 = 0x70;
		const u32 NVKC_F2 = 0x71;
		const u32 NVKC_F3 = 0x72;
		const u32 NVKC_F4 = 0x73;
		const u32 NVKC_F5 = 0x74;
		const u32 NVKC_F6 = 0x75;
		const u32 NVKC_F7 = 0x76;
		const u32 NVKC_F8 = 0x77;
		const u32 NVKC_F9 = 0x78;
		const u32 NVKC_F10 = 0x79;
		const u32 NVKC_F11 = 0x7A;
		const u32 NVKC_F12 = 0x7B;

		const u32 NVKC_NUMPAD0 = 0x60;
		const u32 NVKC_NUMPAD1 = 0x61;
		const u32 NVKC_NUMPAD2 = 0x62;
		const u32 NVKC_NUMPAD3 = 0x63;
		const u32 NVKC_NUMPAD4 = 0x64;
		const u32 NVKC_NUMPAD5 = 0x65;
		const u32 NVKC_NUMPAD6 = 0x66;
		const u32 NVKC_NUMPAD7 = 0x67;
		const u32 NVKC_NUMPAD8 = 0x68;
		const u32 NVKC_NUMPAD9 = 0x69;
		const u32 NVKC_NUMPAD_MUL = 0x6A;
		const u32 NVKC_NUMPAD_ADD = 0x6B;
		const u32 NVKC_NUMPAD_SEP = 0x6C;
		const u32 NVKC_NUMPAD_SUB = 0x6D;
		const u32 NVKC_NUMPAD_DOT = 0x6E;
		const u32 NVKC_NUMPAD_DIV = 0x6F;

		const u32 NVKC_NUMLOCK = 0x90;
		const u32 NVKC_SCRLOCK = 0x91;
		const u32 NVKC_CAPSLOCK = 0x14;

		const u32 NVKC_LSHIFT = 0xA0;
		const u32 NVKC_RSHIFT = 0xA1;
		const u32 NVKC_LCONTROL = 0xA2;
		const u32 NVKC_RCONTROL = 0xA3;
		const u32 NVKC_LMENU = 0xA4;
		const u32 NVKC_RMENU = 0xA5;

		const u32 NVKC_BACKSPACE = 0x08;
		const u32 NVKC_TAB = 0x09;
		const u32 NVKC_ENTER = 0x0D;
		const u32 NVKC_SPACE = 0x20;
		const u32 NVKC_ESCAPE = 0x1B;



		const u32 NVKC_LEFT = 0x01;
		const u32 NVKC_RIGHT = 0x02;
		const u32 NVKC_MIDDLE = 0x04;


	}
}